package com.unionpay.rpc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonAutoDetect;

/**
 * RPC服务器方法
 * 
 * @author liuzy
 */
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
public class RpcMethod {
	private int id = 1;
	private String jsonrpc = "2.0";
	private String method;
	private List<Object> params = new ArrayList<Object>();
	public RpcMethod(String method) {
		this.method = method;
	}
	public RpcMethod(int id, String method) {
		this.id = id;
		this.method = method;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getJsonrpc() {
		return jsonrpc;
	}
	public void setJsonrpc(String jsonrpc) {
		this.jsonrpc = jsonrpc;
	}
	public String getMethod() {
		return method;
	}
	public void setMethod(String method) {
		this.method = method;
	}
	public void addParams(String from, String to, String data) {
		Map<String, String> obj = new HashMap<String, String>();
		obj.put("from", from);
		obj.put("to", to);
		obj.put("data", data);
		this.params.add(obj);
	}
	public void addParams(String from, String data) {
		Map<String, String> obj = new HashMap<String, String>();
		obj.put("from", from);
		obj.put("data", data);
		this.params.add(obj);
		
	}
	public void addParams(String str) {
		this.params.add(str);
	}
	public void addParams(Object str) {
		this.params.add(str);
	}
}
